package com.taptech.doufu.util;

import com.taptech.doufu.weex.notification.QLXNotificationCenter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Wyatt on 2017/8/29/029.
 */

public class NotifyUtil {

    /**
     * app进入后台
     */
    public static void appEnterBackground(){
        QLXNotificationCenter.getInstance().postNotify("AppEnterBackground",null);
    }

    /**
     * app 进入前台
     */
    public static void appEnterForeground(){
        QLXNotificationCenter.getInstance().postNotify("AppEnterForeground",null);
    }

    public static void toasDialog(HashMap<String,String> map) {
        QLXNotificationCenter.getInstance().postNotify("TFSplashCompleteNotificationName",map);
    }



    public static void googlePayNotifySuccess() {
        QLXNotificationCenter.getInstance().postNotify("TFGooglePaySuccessNotify",null);
    }


    public static void shareNotify(String msg) {
        HashMap<String, String> map = new HashMap<>();
        map.put("text",msg);
        QLXNotificationCenter.getInstance().postNotify("TFShareResponseNotify",map);
    }


    /**
     * 收藏状态改变
     * @param id
     * @param objectType
     * @param isColected
     */
    public static void collectStatusChange(String id,int objectType,boolean isColected){
        HashMap<String, String> map = new HashMap<>();
        map.put("object_id", id);
        map.put("object_type", String.valueOf(objectType));
        if (isColected) {
            map.put("isColected", "1");
        }else{
            map.put("isColected", "0");
        }
        QLXNotificationCenter.getInstance().postNotify("TFCollectStatusChangedNotificationName",map);
    }

    public static void thirdLoginWeChatLogin(String code,String msg) {
        HashMap<String, Object> data = new HashMap<>();
        data.put("type", "2");
        data.put("message", msg);
        HashMap<String, String> map = new HashMap<>();
        map.put("code", code);
        data.put("data", map);
        QLXNotificationCenter.getInstance().postNotify("TFThirdLoginWeChatLoginNotify",data);
    }


    public static void successPay() {
        QLXNotificationCenter.getInstance().postNotify("TFThirdPartyPaySuccessNotify",null);
    }

    public static void errorPay(String msg){
        Map<String, String> param = new HashMap<>();
        param.put("msg",msg);
        QLXNotificationCenter.getInstance().postNotify("TFThirdPartyPayErrorNotify",param);
    }

    /**
     * 刷新我的小说页面
     */
    public static void refrushMyNovelListNotify() {
        QLXNotificationCenter.getInstance().postNotify("TFRefrushMyNovelListNotify",null);
    }


    public static void refreshCollectCellNotify(String id, String sectionId, int pos) {
        Map<String, String> param = new HashMap<>();
        param.put("position",String.valueOf(pos));
        param.put("section_id",sectionId);
        QLXNotificationCenter.getInstance().postNotify("CollectPositionUpdateNotify_"+id,param);
    }
}
